<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>验证码</title>
</head>
<body>
    <button id="btn" disabled:false>获取验证码</button>
    <script>
        var timer = null;
        var btn = document.getElementById("btn");
        var settime = 60;
        var n = settime;
        function wait() {
            if (n > 0) {
                n--;
                btn.innerHTML = "等待" + n + "秒后重新获取验证码";
            }else{
                btn.innerHTML = "获取验证码";
                btn.disabled = false;
                clearInterval(timer);
                timer = null;
                n = settime;
            }
        }
        btn.onclick = function() {
            btn.disabled = true;           
            timer = setInterval(wait,1000);
        }
           
        
    </script>
</body>
</html>